<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
<style type="text/css">
.padding-nono {
	margin-bottom: 66px;
}
</style>
</head>
<body class="gray-bg">
	<form id="commentForm" class="content">
		<div class="tche-padding">
			<input type="hidden" id="busiId" name="busiId" /> 
			<input type="hidden" id="cusId" name="cusId" /> 
			<input type="hidden" id="id" name="id" />
			<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
				<tr>
					<td align="right"><label class="control-label np">汇款账号：</label> </td>
					<td><input class="form-control" type="text" id="cardnoRemit" name="cardnoRemit"  placeholder="汇款账号" /></td>
					<td align="right"><label class="control-label np">保险公司：</label> </td>
					<td><input class="form-control" type="text" id="companyInsurance" name="companyInsurance" placeholder="保险公司"/></td>
					<td align="right"><label class="control-label np">保单号：</label> </td>
					<td><input class="form-control" type="text" id="noInsurance" name="noInsurance" placeholder="保单号"  /></td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">出险日：</label> </td>
					<td><input class="smallicontm form-control" type="text" id="dateCompensation" name="dateCompensation" placeholder="出险日 "  onclick="laydate()" /></td>
					<td align="right"><label class="control-label np">受理日：</label> </td>
					<td><input class="smallicontm form-control" type="text" id="dateAccept" name="dateAccept" onclick="laydate()" placeholder="受理日 " /></td>
					<td align="right"><label class="control-label np">送交日：</label> </td>
					<td><input class="smallicontm form-control" type="text" id="dateSend" name="dateSend" required="required"  placeholder="送交日(必填) " onclick="laydate()" /></td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">案件性质：</label> </td>
					<td><input type="hidden" id="natureCase" name="natureCase" />
						<input id="natureCaseDisplay" name="natureCaseDisplay" type="text" placeholder="案件性质 " class="form-control smalliconcur smallicon" readonly="" onclick="ajxzChoice()" /></td>
					<td align="right"><label class="control-label np">事故责任：</label> </td>
					<td colspan="3"><input class="form-control" type="text" id="duty" name="duty"  placeholder="事故责任 " /></td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">代勘察费：</label>
					</td>
					<td><input class="form-control" type="text" id="feeSurvey"
						name="feeSurvey" placeholder="代勘察费 " 
						onkeyup="value=value.replace(/[^\-?\d.]/g,''); countjq();"
						onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countjq();" />
					</td>
					<td align="right"><label class="control-label np">修理费：</label>
					</td>
					<td><input class="form-control" type="text" id="feeRepair"
						name="feeRepair" placeholder="修理费 " 
						onkeyup="value=value.replace(/[^\-?\d.]/g,''); countjq();"
						onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countjq();" />
					</td>
					<td align="right"><label class="control-label np">三者费用：</label>
					</td>
					<td><input class="form-control" type="text" id="feeThird"
						name="feeThird" placeholder="三者费用 " 
						onkeyup="value=value.replace(/[^\-?\d.]/g,''); countjq();"
						onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countjq();" />
					</td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">其他费用：</label>
					</td>
					<td><input class="form-control" type="text" id="feeOther"
						name="feeOther" placeholder="其他费用 " 
						onkeyup="value=value.replace(/[^\-?\d.]/g,''); countjq();"
						onafterpaste="value=value.replace(/[^\-?\d.]/g,''); countjq();" />
					</td>
					<td align="right"><label class="control-label np">合计金额：</label>
					</td>
					<td><input class="form-control" type="text" id="feeTotal" placeholder="合计金额 " 
						name="feeTotal" readonly="readonly" /></td>
					<td align="right"><label class="control-label np">申请理赔金额：</label>
					</td>
					<td><input class="form-control" type="text" placeholder="申请理赔金额 " 
						id="amountIndemnity" name="amountIndemnity" /></td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">退单日：</label>
					</td>
					<td><input class="form-control smallicontm" type="text" placeholder="退单日 " 
						id="dateCacel" name="dateCacel" onclick="laydate()" /></td>
					<td align="right"><label class="control-label np">退单原因：</label>
					</td>
					<td colspan="3"><input class="form-control" type="text" placeholder="退单原因 " 
						id="reasonCacel" name="reasonCacel" /></td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">再送交日：</label>
					</td>
					<td><input class="form-control smallicontm" type="text" placeholder="再送交日 " 
						id="dateAgain" name="dateAgain" onclick="laydate()" /></td>
					<td align="right"><label class="control-label np">收到计算书时间：</label>
					</td>
					<td><input class="smallicontm form-control" type="text" placeholder="收到计算书时间 " 
						id="dateCalculationSheet" name="dateCalculationSheet"
						onclick="laydate()" /></td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">打款日：</label>
					</td>
					<td><input class="smallicontm form-control" type="text" 
						id="dateRemit" name="dateRemit" onclick="laydate()"
						required="required" placeholder="打款日(必填)" /></td>
					<td align="right"><label class="control-label np">打款方式：</label> </td>
					<td colspan="4"><select class="select-control" id="typeRemit" name="typeRemit"></select></td>
				</tr>
				<tr>
					<td align="right"><label class="control-label np">回寄人：</label>
					</td>
					<td><input class="form-control" type="text" placeholder="回寄人(必填)" required="required" id="operatorSendback" name="operatorSendback" /></td>
					<td align="right"><label class="control-label">回寄时间：</label></td>
					<td><input class="smallicontm form-control" type="text" placeholder="回寄时间 (必填)" id="dateSendback" name="dateSendback" required="required" onclick="laydate()" /></td>
					<td align="right"><label class="control-label np">理赔专员：</label>
					</td>
					<td><input class="form-control" type="text" placeholder="理赔专员 " 
						id="operatorSettlement" name="operatorSettlement" /></td>
				</tr>
				<tr>
					<td align="right" valign="top"><label class="control-label np">信息备注：</label>
					</td>
					<td colspan="5"><textarea id="remarks" name="remarks" rows=""
							cols="" class="form-control"></textarea></td>
				</tr>
			</table>
		</div>
		<div class="business-manwife clear-both">经办信息</div>
		<div class="padding-nono">
			<table cellpadding="0" cellspacing="0" border="0"
				class="buyinfor-table">
				<tr>
					<td align="right"><label class="control-label np">经办人：</label>
					</td>
					<td><input type="hidden" id="creator" name="creator"
						value="${current_user_key.id}" /> <input id="creatorName"
						name="creatorName" class="form-control" readonly="readonly"
						value="${current_user_key.uname}" /></td>
					<td align="right"><label class="control-label np">经办时间：</label>
					</td>
					<td><input id="jbTime" name="jbTime" class="laydate-icon form-control" onclick="laydate()" placeholder="经办时间" /></td>
				</tr>
			</table>
		</div>
	</form>
	<div class="div-fixedb">
		<table cellpadding="0" cellspacing="0" border="0" width="100%"
			style="bottom: 0px; margin-bottom: 0px;">
			<tr>
				<td width="100%" align="center">
					<div class="ibox-content" style="clear: none; border: none;">
						<button id="save" class="btn dpbtn_green" type="button"
							onclick="saveAll();">保存提交</button>
						<button id="update" class="btn dpbtn_green" type="button"
							onclick="allUpdate();">修改提交</button>
					</div>
				</td>
			</tr>
		</table>
	</div>

	<div id="layer-message" class="layer-message">
		<ul id="layerUL">
		</ul>
	</div>
	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>

	<!-- layerDate plugin javascript -->
	<script type="text/javascript"
		src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>

	<!-- custom js -->
	<%@include
		file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>

	<!-- layerDate plugin javascript -->
	<script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>

	<script type="text/javascript">
    $(function(){
    	getTypeRemitDIc();
    	$("#busiId").val($.getUrlData("busiId"));
    	$("#cusId").val($.getUrlData("cusId"));
    	$("#id").val($.getUrlData("id"));
    	var id=$.getUrlData("id");
    	if(id!=null && id!=""){
    		$("#save").hide();
    		$("#update").show();
    		getDataById(id);
    	}else{
    		$("#save").show();
    		$("#update").hide();
    	}
		$.dpAjax({
			show:false,
	    	url:'${basePath}/DataDictionaryController/getEnableList',
 			data:{
 				"parentValue":"CompensationCaseNature"
 			},
 			success: function(datas){
 				  var result = datas.result.rows;
				  var content = '';
			      for(var i=0;i<result.length;i++){
			          content +='<li class="layerUL-li" value="'+result[i].value+'">'+result[i].name+'</li>';
			      }
			      $("#layerUL").html(content);
				  $("#layerUL li").on('dblclick',function(){ 
					 var choicetext = $(this).text();
					 var choiceVal= $(this).val()<10?"0"+$(this).val():$(this).val();
					 $("#natureCase").val(choiceVal);
					 $("#natureCaseDisplay").val(choicetext);
					 layer.close(indexlayer);
				  });
				  return;
              }
	    });
		
	});
    
    var getTypeRemitDIc=function(){
    	show:false,
    	$.dpAjax({
	    	url:'${basePath}/DataDictionaryController/getEnableList',
 			data:{"parentValue":"CompensationRemitType"},
 			success: function(datas){
 				  var result = datas.result.rows;
				  var programme_sel=[];
			      for(var i=0;i<result.length;i++){
			          var programme = result[i];
			          programme_sel.push('<option value="'+programme.value+'">'+programme.name+'</option>')
			      }
			      $("#typeRemit").html(programme_sel.join(' '));
				  return;
               }
	    	});
    }
    
    var getDataById=function(id){
		var data={};
		data.id= id;
		$.dpAjax({
    		url:'${basePath}/DhInsuranceCompensationController/getById',
    		data:data,
				success: function(datas){
    				  var data=datas.result;
    				  $("#cardnoRemit").val(data.cardnoRemit);
    				  $("#companyInsurance").val(data.companyInsurance);
    				  $("#noInsurance").val(data.noInsurance);
    				  $("#dateCompensation").val(data.dateCompensation);
    				  $("#dateAccept").val(data.dateAccept);
    				  $("#dateSend").val(data.dateSend);
    				  $("#natureCaseDisplay").val(data.natureCaseDisplay);
    				  $("#natureCase").val(data.natureCase);
    				  $("#duty").val(data.duty);
    				  $("#feeSurvey").val(data.feeSurvey);
    				  $("#feeRepair").val(data.feeRepair);
    				  $("#feeThird").val(data.feeThird);
    				  $("#feeOther").val(data.feeOther);
    				  $("#feeTotal").val(data.feeTotal);
    				  $("#amountIndemnity").val(data.amountIndemnity);
    				  $("#dateCacel").val(data.dateCacel);
    				  $("#reasonCacel").val(data.reasonCacel);
    				  $("#dateAgain").val(data.dateAgain);
    				  $("#dateCalculationSheet").val(data.dateCalculationSheet);
    				  $("#dateRemit").val(data.dateRemit);
    				  var t1 = document.getElementById("typeRemit");   
  	      	        	for(i=0;i<t1.length;i++){//给select赋值  
  	      	            if(data.typeRemit==t1.options[i].value){  
  	      	                t1.options[i].selected=true;  
  	      	            }  
  	      	        }
    				  $("#operatorSendback").val(data.operatorSendback);
    				  $("#dateSendback").val(data.dateSendback);
    				  $("#operatorSettlement").val(data.operatorSettlement);
    				  $("#remarks").val(data.remarks);
    				  $("#creatorName").val(data.creatorName);
    				  $("#jbTime").val(data.jbTime);
    				  layer.msg('执行成功！', {icon: 6});
					  return;
            }
    	});
	}
    
    var allUpdate=function(){
    	var data = {};
    	data.id=$("#id").val();
    	data.cardnoRemit=$("#cardnoRemit").val();
    	data.companyInsurance= $("#companyInsurance").val();
    	data.noInsurance=$("#noInsurance").val();
    	data.dateCompensation=  $("#dateCompensation").val();
    	data.dateAccept=  $("#dateAccept").val();
    	data.dateSend=  $("#dateSend").val();
    	data.natureCase=  $("#natureCase").val();
    	data.duty= $("#duty").val();
    	data.feeSurvey=  $("#feeSurvey").val();
    	data.feeRepair=  $("#feeRepair").val();
    	data.feeThird=  $("#feeThird").val();
    	data.feeOther=  $("#feeOther").val();
    	data.feeTotal=  $("#feeTotal").val();
    	data.amountIndemnity=  $("#amountIndemnity").val();
    	data.dateCacel=  $("#dateCacel").val();
    	data.reasonCacel=  $("#reasonCacel").val();
    	data.dateAgain=  $("#dateAgain").val();
    	data.dateCalculationSheet=  $("#dateCalculationSheet").val();
    	data.dateRemit=  $("#dateRemit").val();
//     	data.typeRemit= $("#typeRemit").val();
    	data.typeRemit=$('#typeRemit option:selected').val();
    	data.operatorSendback=  $("#operatorSendback").val();
    	data.dateSendback=  $("#dateSendback").val();
    	data.operatorSettlement=  $("#operatorSettlement").val();
    	data.remarks=  $("#remarks").val();
    	data.jbTime=$("#jbTime").val();
    	data.insuranceId=$.getUrlData("insuranceId");
    	$.dpAjax({
    		url:'${basePath}/DhInsuranceCompensationController/modify',
    		data:data,
			success: function(datas){
				  layer.msg('执行成功！', {icon: 6});
  				  parent.layer.close(parent.changelayer);
				  parent.refresh();
				  return;
            }
    	});
    }
    
    var countjq=function(){
  	  var feeSurvey=$("#feeSurvey").val()==""?"0":$("#feeSurvey").val();
  	  var feeRepair=$("#feeRepair").val()==""?"0":$("#feeRepair").val();
  	  var feeThird=$("#feeThird").val()==""?"0":$("#feeThird").val();
  	  var feeOther=$("#feeOther").val()==""?"0":$("#feeOther").val();
  	  var total=parseFloat(feeSurvey)+parseFloat(feeRepair)+parseFloat(feeThird)+parseFloat(feeOther);
  	  $("#feeTotal").val(total);
    }
    
    var saveAll=function(){
		var data={};
		data.cardnoRemit=$("#cardnoRemit").val();
    	data.companyInsurance= $("#companyInsurance").val();
    	data.noInsurance=$("#noInsurance").val();
    	data.dateCompensation=  $("#dateCompensation").val();
    	data.dateAccept=  $("#dateAccept").val();
    	data.dateSend=  $("#dateSend").val();
    	data.natureCase=  $("#natureCase").val();
    	data.duty= $("#duty").val();
    	data.feeSurvey=  $("#feeSurvey").val();
    	data.feeRepair=  $("#feeRepair").val();
    	data.feeThird=  $("#feeThird").val();
    	data.feeOther=  $("#feeOther").val();
    	data.feeTotal=  $("#feeTotal").val();
    	data.amountIndemnity=  $("#amountIndemnity").val();
    	data.dateCacel=  $("#dateCacel").val();
    	data.reasonCacel=  $("#reasonCacel").val();
    	data.dateAgain=  $("#dateAgain").val();
    	data.dateCalculationSheet=  $("#dateCalculationSheet").val();
    	data.dateRemit=  $("#dateRemit").val();
    	data.typeRemit=$('#typeRemit option:selected').val();
    	data.operatorSendback=  $("#operatorSendback").val();
    	data.dateSendback=  $("#dateSendback").val();
    	data.operatorSettlement=  $("#operatorSettlement").val();
    	data.remarks=  $("#remarks").val();
    	data.jbTime=$("#jbTime").val();
    	data.busiId=$.getUrlData("busiId");
    	data.cusId=$.getUrlData("cusId");
    	data.insuranceId=$.getUrlData("insuranceId");
    	var validstatus = $("#commentForm").valid();
    	if(!validstatus){
    		layer.msg('有资料未正确填写，请检查！', {icon: 5});
    		return;
    	}
    	$.dpAjax({
    		url:'${basePath}/DhInsuranceCompensationController/save',
    		data:data,
			success: function(datas){
				 layer.msg('执行成功！', {icon: 6});
  				     parent.layer.close(parent.creatorderlayer);
			 	 parent.refresh();
				 return;
            }
    	});
    }
  
    var indexlayer;
    var ajxzChoice=function(){
    	indexlayer=layer.open({
			  title:'案件性质选择',
			  type: 1,
			  area: ['350px', '400px'], //宽高
			  content: $('#layer-message')
			}); 
    }
    
    $(function(){	
        $("#commentForm").validate({
            //重写showErrors
            showErrors: function (errorMap, errorList) {
                
                $.each(errorList, function (i, v) {
                    layer.tips(v.message, v.element, { time: 1500 });
                    return false;
                });  
            },
            /* 失去焦点时验证 */
            onfocusout: function(element) { $(element).valid(); },
            /*  键盘抬起不验证 */
            onkeyup:false,
        });
        
	})
	
    </script>
</body>
</html>
